package com.briup.recognition.service.impl;

import com.briup.recognition.bean.RolePrivilege;
import com.briup.recognition.bean.RolePrivilegeExample;
import com.briup.recognition.dao.RolePrivilegeMapper;
import com.briup.recognition.service.RolePrivilegeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 冯琼华
 * @Date: 2021/03/29/12:42
 * @Description:
 */

@Service
public class RolePrivilegeImpl implements RolePrivilegeService {

    @Resource
    private RolePrivilegeMapper rolePrivilegeMapper;

    @Override
    public List<RolePrivilege> query() {
        RolePrivilegeExample example = new RolePrivilegeExample();

        return rolePrivilegeMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(RolePrivilege rolePrivilege) {
        if(rolePrivilege.getId() != null){
            rolePrivilegeMapper.updateByPrimaryKey(rolePrivilege);
        }else {
            rolePrivilegeMapper.insert(rolePrivilege);
        }
    }

    @Override
    public void deleteById(long id) {
        rolePrivilegeMapper.deleteByPrimaryKey(id);
    }
}
